﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;
using LGE;

namespace YouOnlyGetOne
{
    public class Coin : GameObject
    {
        public static List<Texture2D> Textures = new List<Texture2D>();

        String GetCueName { get { return "coin_" + (value > 0 ? "up" : "down") + "_pick"; } }

        int value = 0;
        SpriteSheet ss;

        public Coin(PlayScreen ps, Vector2 pos)
            : base(ps, null)
        {
            this.position = pos;
            while (value == 0)
                value = Rand.Next(1, 12) - 6;
            ss = new SpriteSheet(this, 48, 61, 100, true);
            sprite = Textures[(value + 5) + (value > 0 ? -1 : 0)];

            sourceRectangle = new Rectangle(0, 0, 48, 61);
            HitBox = new Rectangle(0, 0, 48, 61);
            origin = new Vector2(sourceRectangle.Width / 2, sourceRectangle.Height / 2);
        }

        public override void Update(GameTime gameTime)
        {
            ss.Update(gameTime);
            if (Collision(ps.player))
            {
                ps.player.coins++;
                ps.player.points += value;
                alive = false;
                Audio.PlayCue(GetCueName);
            }
        }
    }
}
